package com.nf.health.app.activity.manage_health;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.widget.DefaultItemAnimator;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.TextView;

import com.nf.health.app.R;
import com.nf.health.app.activity.global.BaseActivity;
import com.nf.health.app.activity.manage_health.adapter.PreventionChronicAdapter;
import com.nf.health.app.utils.ViewUtil;

/**
 * 慢性病智慧防控计划
 * @auther changpeng
 * 20l7 06 01
 */
public class PreventionChronicActivity extends BaseActivity {

    private RecyclerView mRecyclerView;
    private PreventionChronicAdapter mAdapter;
    private TextView mActivityTitle;
    private static final int BLOOD_PRESSURE = 1;
    private static final int BLOOD_SUGAR = 2;
    private static final String TYPE_KEY = "type";
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setTitleBar(R.layout.titlebar_base);
        setContent(R.layout.common_layout_recycler);
        initView();
        initListener();
    }

    private void initView(){
        mRecyclerView = ViewUtil.getView(this, R.id.recycler_view_common);
        mActivityTitle = ViewUtil.getView(this, R.id.titlebar_title_tv);
        mAdapter = new PreventionChronicAdapter(this);
        mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
        mRecyclerView.setItemAnimator(new DefaultItemAnimator());
        mRecyclerView.setAdapter(mAdapter);

        mActivityTitle.setText("慢性病智慧防控计划");
    }

    private void initListener(){
        mAdapter.setOnItemClickLitener(new PreventionChronicAdapter.OnItemClickLitener() {
            @Override
            public void onItemClick(View view, int position) {
                Intent intent = new Intent(PreventionChronicActivity.this,PreventionBloodPressureActivity.class);
                switch (position){
                    case BLOOD_PRESSURE:
                        //高血压
                        intent.putExtra(TYPE_KEY,BLOOD_PRESSURE);
                        break;
                    case BLOOD_SUGAR:
                        //糖尿病
                        intent.putExtra(TYPE_KEY,BLOOD_SUGAR);
                        break;
                }
                startActivity(intent);
                finish();
            }

            @Override
            public void onItemLongClick(View view, int position) {

            }
        });
    }

}
